using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace WebTester
{
    public partial class WebData : Form
    {
        public WebData()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(this.txt_URL.Text.Trim());
            HttpWebResponse hwrp = (HttpWebResponse)hwr.GetResponse();
            WebHeaderCollection whc = hwrp.Headers;

            string header = null, html = null;

            for (int i = 0; i < whc.Count; i++)
            {
                header += whc.GetKey(i) + "=" + whc.GetKey(i) + "\r\n";
            }

            Stream strm = hwrp.GetResponseStream();
            StreamReader sr = new StreamReader(strm);

            while (sr.Peek() > -1)
            {
                html += sr.ReadLine() + "\r\n";
            }

            this.textBox2.Text = header;
            this.textBox3.Text = html;

            sr.Close();
            strm.Close();

        }
    }
}